import time, sys
sys.path.append('./base_api')
sys.path.append('./fixture')
from HTMLTestRunner import HTMLTestRunner
import unittest



# 指定测试用例为当前文件夹下的 api 目录
test_dir = './api'
discover = unittest.defaultTestLoader.discover(test_dir, pattern='*_test.py')


if __name__ == "__main__":
    # test_data.init_data() # 初始化接口测试数据

    now = time.strftime("%Y-%m-%d %H_%M_%S")
    filename = './report/' + now + '_response.html'
    fp = open(filename, 'wb')
    #HTMLTestRunner可以读''' '''
    runner = HTMLTestRunner(stream=fp,     #stream指定测试报告文件
                            title='huizu',
                            description='用例执行情况')
    runner.run(discover)
    fp.close()